<template>
  <img alt="Vue logo" src="./assets/logo.png"/>
  <input type="text" v-model="message" @keyup="onInputKeyUp">
  {{ message }}
  <br/>
  {{ user }}
  <br/>
  {{ users }}
  <br/>
  <br/>
  <br/>
  <!--  <HelloWorld msg="Hello Vue 3 + TypeScript + Vite"/>-->
  {{ appName }}xxx
  {{ apiDomain }}VITE_API_DOMAIN
</template>

<script setup lang="ts">
// This starter template is using Vue 3 <script setup> SFCs
// Check out https://v3.vuejs.org/api/sfc-script-setup.html#sfc-script-setup
import HelloWorld from './components/HelloWorld.vue'
import {ref, Ref, isRef, reactive} from 'vue'

const appName: Ref<object> = ref<object>(import.meta.env.VITE_APP_NAME)
const apiDomain: Ref<object> = ref<object>(import.meta.env.VITE_API_DOMAIN)

// 通过ref()函数创建响应式对象，返回Ref<T>类型对象
const message: Ref<string> = ref<string>('我是李达康')

const onInputKeyUp = () => {
  // 通过.value获取值
  console.log(message.value);
  // 判断某个对象是否是Ref类型
  console.log(isRef(message));
}

// 复杂对象和数组
const user = reactive({
  username: '李达康',
  age: 18,
  message: message
})
const users = reactive([user, user])

</script>

<style>
#app {
  font-family: Avenir, Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-align: center;
  color: #2c3e50;
  margin-top: 60px;
}
</style>
